package com.graduation.mobile.controller;

import java.util.List;
import java.util.Map;

import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import cn.circle.commom.dao.impl.BaseDaoImpl;
import com.graduation.system.model.SysDepartment;

import cn.circle.system.service.ISysDepartmentService;
import cn.circle.system.util.DataGrid;
import cn.circle.system.util.ReturnInfo;

@Controller
@EnableWebMvc
public class MobileMainController extends BaseDaoImpl<SysDepartment>{

	@Autowired
	private ISysDepartmentService sysDepaermentService;
	
	@RequestMapping(value = "/mobile/personal")
	public String personal(Map<String, Object> map) {
		List<SysDepartment> dep = this.getDepartment().getRows();
		map.put("dep", dep);
		return "/WEB-INF/jsp/mobile/main/personMobile/personMobile.jsp";
	}
	@RequestMapping(value = "/mobile/goRegister")
	public String index() {
		return "/WEB-INF/jsp/mobile/main/register.jsp";
	}
	
	@RequestMapping(value = "/mobile/goMain")
	public String goMain() {
		return "/WEB-INF/jsp/mobile/main/schoolLive/main_LiveCircle.jsp";
	}
	
	@RequestMapping(value = "/mobile/goschoolLive")
	public String goSchoolLive() {
		return "/WEB-INF/jsp/mobile/main/schoolLive/main_schoolLive.jsp";
	}
	
	@RequestMapping(value = "/mobile/goPerson")
	public String goPerson() {
		return "/WEB-INF/jsp/mobile/main/schoolLive/main_person.jsp";
	}
	
	@RequestMapping(value = "/mobile/LostAndFound")
	public String goLostAndFound() {
		return "/WEB-INF/jsp/mobile/main/schoolLive/LostAndFound/LostAndFound.jsp";
	}
	
	@RequestMapping(value = "/mobile/goSendLAF")
	public String goSendLAF() {
		return "/WEB-INF/jsp/mobile/main/schoolLive/LostAndFound/sendLAF.jsp";
	}

	@ResponseBody
	@RequestMapping(value = "/mobile/getJson")
	public ReturnInfo getJson(ReturnInfo r) {
		
		String hql = "from SysDepartment ";
		
		Query query = super.sessionFactory.getCurrentSession().createQuery(hql);
		List<SysDepartment> l = query.list();
		r.setMsg("shishi");
		r.setObj(l);
		r.setSuccess(0);
		return r;
	}
	/**
	 * 获取部门信息
	 */
	public DataGrid getDepartment(){
		return sysDepaermentService.datagrid();
	}
	
}
